
/*
\ brief:  实现文件
\ author: 清晨与猫鱼
*/
#include <iostream>     // 标准输入输出库
#include <memory>       // 内存管理库

using namespace std;

/*
\ brief:  抽象接口类
\ author: 清晨与猫鱼
*/
class DrawAPI {
public:
    virtual void drawCircle(int radius, int x, int y) = 0;  // 绘制圆接口函数
};


/*
\ brief:  红色圆形
\ author: 清晨与猫鱼
*/
class RedCircle 
    : public DrawAPI {
public:
    void drawCircle(int radius, int x, int y) {
        cout << "Drawing Circle[ color: red, radius: "
        << radius << ", x: " << x << ", " << y << endl;
    }
};


/*
\ brief:  绿色圆形
\ author: 清晨与猫鱼
*/
class GreenCircle 
    : public DrawAPI {
public:
    void drawCircle(int radius, int x, int y) {
        cout << "Drawing Circle[ color: green, radius: " << radius <<
        ", x: " << x << ", " << y << endl;
    }
};


/*
\ brief:  形状抽象接口
\ author: 清晨与猫鱼
*/
class Shape {
public:
    explicit Shape(DrawAPI* drawAPI) 
        : drawAPI_(drawAPI){
    }

    virtual void draw() = 0;        // 绘制接口函数
protected:
   unique_ptr<DrawAPI> drawAPI_;        // 成员变量是绘制抽象接口
};


/*
\ brief:  圆
\ author: 清晨与猫鱼
*/
class Circle 
    : public Shape {
public:
    explicit Circle(int x, int y, int radius, DrawAPI* drawAPI)
        : Shape(drawAPI), x_(x), y_(y), radius_(radius){
    }

    void draw() {
        drawAPI_->drawCircle(radius_, x_, y_);
    }

private:
    int x_, y_, radius_;        // 绘制参数变量
};